//  To parse this JSON data, first install
//
//      Boost     http://www.boost.org
//      json.hpp  https://github.com/nlohmann/json
//
//  Then include this file, and then do
//
//     RealResult data = nlohmann::json::parse(jsonString);

#pragma once

#include "json.hpp"

#include <boost/optional.hpp>
#include <stdexcept>
#include <regex>

namespace JsonSchema.S0017.Device.RealResult_NS {
    using nlohmann::json;

    #ifndef NLOHMANN_UNTYPED_JsonSchema.S0017.Device.RealResult_NS_HELPER
    #define NLOHMANN_UNTYPED_JsonSchema.S0017.Device.RealResult_NS_HELPER
    inline json get_untyped(const json & j, const char * property) {
        if (j.find(property) != j.end()) {
            return j.at(property).get<json>();
        }
        return json();
    }

    inline json get_untyped(const json & j, std::string property) {
        return get_untyped(j, property.data());
    }
    #endif

    /**
     * 主体数据
     */
    class Body {
        public:
        Body() = default;
        virtual ~Body() = default;

        private:
        std::string team;
        std::string athlete_name;
        std::string athlete_bib;
        std::string athlete_telephone;
        std::string result_a;
        std::string result_b;
        std::string rank;

        public:
        /**
         * 代表队/代表团/俱乐部
         */
        const std::string & get_team() const { return team; }
        std::string & get_mutable_team() { return team; }
        void set_team(const std::string & value) { this->team = value; }

        /**
         * 运动员姓名
         */
        const std::string & get_athlete_name() const { return athlete_name; }
        std::string & get_mutable_athlete_name() { return athlete_name; }
        void set_athlete_name(const std::string & value) { this->athlete_name = value; }

        /**
         * 运动员号码
         */
        const std::string & get_athlete_bib() const { return athlete_bib; }
        std::string & get_mutable_athlete_bib() { return athlete_bib; }
        void set_athlete_bib(const std::string & value) { this->athlete_bib = value; }

        /**
         * 运动员联系方式
         */
        const std::string & get_athlete_telephone() const { return athlete_telephone; }
        std::string & get_mutable_athlete_telephone() { return athlete_telephone; }
        void set_athlete_telephone(const std::string & value) { this->athlete_telephone = value; }

        /**
         * A线成绩
         */
        const std::string & get_result_a() const { return result_a; }
        std::string & get_mutable_result_a() { return result_a; }
        void set_result_a(const std::string & value) { this->result_a = value; }

        /**
         * B线成绩
         */
        const std::string & get_result_b() const { return result_b; }
        std::string & get_mutable_result_b() { return result_b; }
        void set_result_b(const std::string & value) { this->result_b = value; }

        /**
         * 排名
         */
        const std::string & get_rank() const { return rank; }
        std::string & get_mutable_rank() { return rank; }
        void set_rank(const std::string & value) { this->rank = value; }
    };

    /**
     * 头部数据
     */
    class Head {
        public:
        Head() = default;
        virtual ~Head() = default;

        private:
        std::string device_id;
        std::string message_uuid;
        std::string timestamp;
        std::string message_type;

        public:
        /**
         * 设备Id
         */
        const std::string & get_device_id() const { return device_id; }
        std::string & get_mutable_device_id() { return device_id; }
        void set_device_id(const std::string & value) { this->device_id = value; }

        /**
         * 消息Uuid
         */
        const std::string & get_message_uuid() const { return message_uuid; }
        std::string & get_mutable_message_uuid() { return message_uuid; }
        void set_message_uuid(const std::string & value) { this->message_uuid = value; }

        /**
         * 发送消息的时间。格式：yyyy-MM-dd HH:mm:ss.fff 比如：2020-09-02 12:24:09.923
         */
        const std::string & get_timestamp() const { return timestamp; }
        std::string & get_mutable_timestamp() { return timestamp; }
        void set_timestamp(const std::string & value) { this->timestamp = value; }

        /**
         * 消息类型
         */
        const std::string & get_message_type() const { return message_type; }
        std::string & get_mutable_message_type() { return message_type; }
        void set_message_type(const std::string & value) { this->message_type = value; }
    };

    /**
     * 实时成绩
     */
    class RealResult {
        public:
        RealResult() = default;
        virtual ~RealResult() = default;

        private:
        Head head;
        Body body;

        public:
        /**
         * 头部数据
         */
        const Head & get_head() const { return head; }
        Head & get_mutable_head() { return head; }
        void set_head(const Head & value) { this->head = value; }

        /**
         * 主体数据
         */
        const Body & get_body() const { return body; }
        Body & get_mutable_body() { return body; }
        void set_body(const Body & value) { this->body = value; }
    };
}

namespace JsonSchema.S0017.Device.RealResult_NS {
    void from_json(const json & j, Body & x);
    void to_json(json & j, const Body & x);

    void from_json(const json & j, Head & x);
    void to_json(json & j, const Head & x);

    void from_json(const json & j, RealResult & x);
    void to_json(json & j, const RealResult & x);

    inline void from_json(const json & j, Body& x) {
        x.set_team(j.at("Team").get<std::string>());
        x.set_athlete_name(j.at("AthleteName").get<std::string>());
        x.set_athlete_bib(j.at("AthleteBib").get<std::string>());
        x.set_athlete_telephone(j.at("AthleteTelephone").get<std::string>());
        x.set_result_a(j.at("ResultA").get<std::string>());
        x.set_result_b(j.at("ResultB").get<std::string>());
        x.set_rank(j.at("Rank").get<std::string>());
    }

    inline void to_json(json & j, const Body & x) {
        j = json::object();
        j["Team"] = x.get_team();
        j["AthleteName"] = x.get_athlete_name();
        j["AthleteBib"] = x.get_athlete_bib();
        j["AthleteTelephone"] = x.get_athlete_telephone();
        j["ResultA"] = x.get_result_a();
        j["ResultB"] = x.get_result_b();
        j["Rank"] = x.get_rank();
    }

    inline void from_json(const json & j, Head& x) {
        x.set_device_id(j.at("DeviceId").get<std::string>());
        x.set_message_uuid(j.at("MessageUuid").get<std::string>());
        x.set_timestamp(j.at("Timestamp").get<std::string>());
        x.set_message_type(j.at("MessageType").get<std::string>());
    }

    inline void to_json(json & j, const Head & x) {
        j = json::object();
        j["DeviceId"] = x.get_device_id();
        j["MessageUuid"] = x.get_message_uuid();
        j["Timestamp"] = x.get_timestamp();
        j["MessageType"] = x.get_message_type();
    }

    inline void from_json(const json & j, RealResult& x) {
        x.set_head(j.at("Head").get<Head>());
        x.set_body(j.at("Body").get<Body>());
    }

    inline void to_json(json & j, const RealResult & x) {
        j = json::object();
        j["Head"] = x.get_head();
        j["Body"] = x.get_body();
    }
}
